<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .d1{
            width:600px;
            height: 600px;
            border:1px solid red;
        }
        .d2{
            width:300px;
            height: 300px;
            border:1px solid green;
        }
        .d3{
            width:100px;
            height: 100px;
            border:1px solid hotpink;
        }
    </style>
    <script>
        window.onload=function(){
            var d1=document.querySelector(".d1");
            var d2=document.querySelector(".d2");
            var d3=document.querySelector(".d3");
            d1.onclick=function(){
                alert("d1");
            };
            d2.onclick=function(e){
                alert("d2");
                e.stopPropagation();//阻止事件冒泡
            };
            d3.onclick=function(e){
                alert("d3");
                e.stopPropagation();//阻止事件冒泡
            };
        };
    </script>
</head>
<body>
    <div class="d1">
        <div class="d2">
            <div class="d3"></div>
        </div>
    </div>
</body>
</html>